﻿<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false"
    CodeFile="Executed.aspx.vb" Inherits="Executed" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Title" runat="Server">Εκτελεσθείσες</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="mainContent" runat="Server">
    <br />
    <asp:GridView ID="GridView1" runat="server" DataSourceID="sqldsExecuted" AllowPaging="True"
        AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333"
        GridLines="None" PageSize="15" DataKeyNames="id_Ektelestheises">
        <PagerSettings Mode="NumericFirstLast" Position="TopAndBottom" />
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
        <Columns>
            <asp:TemplateField ShowHeader="False">
                <EditItemTemplate>
                    <asp:ImageButton ID="ImageButton1" runat="server" CausesValidation="True" CommandName="Update"
                        Text="Update" ImageUrl="~/img/update.gif" />
                    &nbsp;<asp:ImageButton ID="ImageButton2" runat="server" CausesValidation="False"
                        CommandName="Cancel" Text="Cancel" ImageUrl="~/img/cbx0.gif" />
                    &nbsp;<asp:ImageButton ID="ImageButton3" runat="server" CausesValidation="False"
                        CommandName="Delete" Text="Delete" ImageUrl="~/img/del.gif" />
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:ImageButton ID="ImageButton1" runat="server" CausesValidation="False" CommandName="Edit"
                        Text="Edit" ImageUrl="~/img/edit.gif" />
                </ItemTemplate>
                <FooterTemplate>
                    <asp:ImageButton ID="ImageButton1" runat="server" CausesValidation="False" CommandName="New"
                        Text="New" ImageUrl="~/img/cbx1.gif" />
                    &nbsp;<asp:ImageButton ID="ImageButton2" runat="server" CausesValidation="False"
                        CommandName="CancelNew" Text="Cancel" ImageUrl="~/img/cbx0.gif" />
                </FooterTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Α/Α" InsertVisible="False" SortExpression="id_Ektelestheises">
                <EditItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("id_Ektelestheises") %>' />
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("id_Ektelestheises") %>' />
                </ItemTemplate>
                <FooterTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("id_Ektelestheises") %>' />
                </FooterTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Στρατεύσιμος" SortExpression="id_Stratefsimos">
                <EditItemTemplate>
                    <asp:DropDownList ID="ddlid_Stratefsimos" runat="Server" SelectedValue='<%# Bind("id_Stratefsimos") %>'
                        DataSourceID="sqldsStaff" DataTextField="DisplayName" DataValueField="id_Stratefsimos" />
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lbltxtid_Stratefsimos" runat="server" Text='<%# Bind("DisplayName") %>' />
                </ItemTemplate>
                <FooterTemplate>
                    <asp:DropDownList ID="ddlid_Stratefsimos" runat="Server" SelectedValue='<%# Bind("id_Stratefsimos") %>'
                        DataSourceID="sqldsStaff" DataTextField="DisplayName" DataValueField="id_Stratefsimos">
                    </asp:DropDownList>
                </FooterTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Τύπος" SortExpression="id_Typos">
                <EditItemTemplate>
                    <asp:DropDownList ID="ddlid_Typos" runat="Server" SelectedValue='<%# Bind("id_Typos") %>'
                        DataSourceID="sqldsTypes" DataTextField="Typos" DataValueField="id_Typos" />
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("Typos") %>'></asp:Label>
                </ItemTemplate>
                <FooterTemplate>
                    <asp:DropDownList ID="ddlid_Typos" runat="Server" SelectedValue='<%# Bind("id_Typos") %>'
                        DataSourceID="sqldsTypes" DataTextField="Typos" DataValueField="id_Typos" />
                </FooterTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Ημερομηνία" SortExpression="Hmeromhnia">
                <EditItemTemplate>
                    <asp:TextBox ID="txtHmeromhnia" runat="server" Text='<%# Bind("Hmeromhnia", "{0:dd/MM/yyyy}") %>'></asp:TextBox>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Λάθος Ημερομηνία!"
                        ControlToValidate="txtHmeromhnia" ValidationExpression="\d{2}/\d{2}/\d{4}"
                        Display="Dynamic"></asp:RegularExpressionValidator>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblHmeromhnia" runat="server" Text='<%# Bind("Hmeromhnia", "{0:dd/MM/yyyy}") %>'></asp:Label>
                </ItemTemplate>
                <FooterTemplate>
                    <asp:TextBox ID="txtHmeromhnia" runat="server" Text='<%# Bind("Hmeromhnia", "{0:dd/MM/yyyy}") %>'></asp:TextBox>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Λάθος Ημερομηνία!"
                        ControlToValidate="txtHmeromhnia" ValidationExpression="\d{2}/\d{2}/\d{4}"
                        Display="Dynamic"></asp:RegularExpressionValidator>
                </FooterTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Α/Α Σκοπιάς" SortExpression="aa_Skopias">
                <EditItemTemplate>
                    <asp:TextBox ID="txtaa_Skopias" runat="server" Text='<%# Bind("aa_Skopias") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblaa_Skopias" runat="server" Text='<%# Bind("aa_Skopias") %>'></asp:Label>
                </ItemTemplate>
                <FooterTemplate>
                    <asp:TextBox ID="txtaa_Skopias" runat="server" Text='<%# Bind("aa_Skopias") %>'></asp:TextBox>
                </FooterTemplate>
            </asp:TemplateField>
        </Columns>
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <EditRowStyle BackColor="#999999" />
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
    </asp:GridView>
    <asp:Button ID="btnInsert" runat="server" Text="Προσθήκη" />    
    <hr />
    <asp:ListBox ID="ListBox1" runat="server" DataSourceID="sqldsSquadrons" DataTextField="Moira"
        DataValueField="id_Moira" SelectionMode="Multiple"></asp:ListBox>
    <br />
    <asp:Button ID="Button1" runat="server" Text="Προβολή" />
    <asp:SqlDataSource ID="sqldsSquadrons" runat="server" ConnectionString="<%$ ConnectionStrings:_112CW_DBConnectionString %>"
        SelectCommand="SELECT * FROM [KNX_Moires]"></asp:SqlDataSource>
    <asp:SqlDataSource ID="sqldsTypes" runat="server" ConnectionString="<%$ ConnectionStrings:_112CW_DBConnectionString %>"
        SelectCommand="SELECT [id_Typos], [Typos] FROM [AMN_Typos]"></asp:SqlDataSource>
    <asp:SqlDataSource ID="sqldsStaff" runat="server" ConnectionString="<%$ ConnectionStrings:_112CW_DBConnectionString %>"
        SelectCommand="select *, Eponimo + ' '  + Onoma + ' ' + Patronimo as DisplayName from STR_Stratefsimoi">
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="sqldsExecuted" runat="server" ConnectionString="<%$ ConnectionStrings:_112CW_DBConnectionString %>"
        DeleteCommand="DELETE FROM [AMN_Ektelestheises] WHERE [id_Ektelestheises] = @id_Ektelestheises"
        InsertCommand="INSERT INTO [AMN_Ektelestheises] ([id_Stratefsimos], [id_Typos], [Hmeromhnia], [aa_Skopias]) VALUES (@id_Stratefsimos, @id_Typos, @Hmeromhnia, @aa_Skopias)"
        SelectCommand="
SELECT  AMN_Ektelestheises.id_Ektelestheises,
        AMN_Ektelestheises.id_Typos,
        AMN_Ektelestheises.Hmeromhnia,
        AMN_Ektelestheises.aa_Skopias,
        STR_Stratefsimoi.Eponimo,
        STR_Stratefsimoi.Onoma,
        STR_Stratefsimoi.Eponimo + ' ' + STR_Stratefsimoi.Onoma AS DisplayName,
        STR_Stratefsimoi.id_Stratefsimos,
        AMN_Typos.Typos,
        KNX_Moires.id_Moira,
        KNX_Moires.Moira
FROM    KNX_Moires
        INNER JOIN STR_Stratefsimoi
        ON KNX_Moires.id_Moira = STR_Stratefsimoi.id_Moira
        INNER JOIN AMN_Ektelestheises
        INNER JOIN AMN_Typos
        ON AMN_Ektelestheises.id_Typos = AMN_Typos.id_Typos
        ON STR_Stratefsimoi.id_Stratefsimos = AMN_Ektelestheises.id_Stratefsimos" UpdateCommand="UPDATE [AMN_Ektelestheises] SET [id_Stratefsimos] = @id_Stratefsimos, [id_Typos] = @id_Typos, [Hmeromhnia] = @Hmeromhnia, [aa_Skopias] = @aa_Skopias WHERE [id_Ektelestheises] = @id_Ektelestheises">
        <DeleteParameters>
            <asp:Parameter Name="id_Ektelestheises" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="id_Stratefsimos" Type="Int32" />
            <asp:Parameter Name="id_Typos" Type="Int32" />
            <asp:Parameter Name="Hmeromhnia" Type="DateTime" />
            <asp:Parameter Name="aa_Skopias" Type="Int32" />
            <asp:Parameter Name="id_Ektelestheises" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="id_Stratefsimos" Type="Int32" />
            <asp:Parameter Name="id_Typos" Type="Int32" />
            <asp:Parameter Name="Hmeromhnia" Type="DateTime" />
            <asp:Parameter Name="aa_Skopias" Type="Int32" />
        </InsertParameters>
    </asp:SqlDataSource>
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
</asp:Content>
